require('dotenv').config();
const sequelize = require('./config/db');
const User = require('./models/User');

(async () => {
  try {
    // 测试数据库连接
    await sequelize.authenticate();
    console.log('数据库连接成功');
    
    // 同步模型到数据库
    await sequelize.sync({ alter: true });
    console.log('所有模型已同步');
  } catch (error) {
    console.error('同步模型时出错:', error);
  } finally {
    // 关闭数据库连接
    await sequelize.close();
  }
})();
